package com.alibaba.citrus.cr.mn.order.center.facade.service.impl;

import com.alibaba.citrus.cr.common.enums.GeneralStatusEnum;
import com.alibaba.citrus.cr.common.enums.ordercenter.*;
import com.alibaba.citrus.cr.common.exception.FacadeException;
import com.alibaba.citrus.cr.common.exception.FunctionException;
import com.alibaba.citrus.cr.mn.order.center.common.constants.ForecastConstants;
import com.alibaba.citrus.cr.mn.order.center.common.util.AssertUtils;
import com.alibaba.citrus.cr.mn.order.center.facade.adapter.BaseDataServiceAdapter;
import com.alibaba.citrus.cr.mn.order.center.facade.adapter.DictionaryVerifyAdapter;
import com.alibaba.citrus.cr.mn.order.center.facade.function.convert.OrderLineBizQueryRequestToOrderLineRepoQueryReqConvertor;
import com.alibaba.citrus.cr.mn.order.center.facade.function.convert.OrderLineSDOToOrderLineBizQueryResponseConvertor;
import com.alibaba.citrus.cr.mn.order.center.facade.function.convert.OrderSDOToOrderBizQueryResponseConvertor;
import com.alibaba.citrus.cr.mn.order.center.facade.repository.OrderLineQueryRepository;
import com.alibaba.citrus.cr.mn.order.center.facade.repository.OrderQueryRepository;
import com.alibaba.citrus.cr.mn.order.center.facade.service.OrderBizDomainService;
import com.alibaba.cz.base.tool.Nullable;
import com.alibaba.cz.base.tool.log.Log;
import com.alibaba.lattice2.epoch.sdk.model.Result;
import com.epoch.app.crb2btradecenter.obtcsaleorderlineindex.model.ObtcSaleOrderLineIndex;
import com.epoch.app.mnordercenter.contants.MnOrderCenterConstants;
import com.epoch.app.mnordercenter.model.dto.*;
import com.google.common.collect.Lists;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.function.Function;
import java.util.stream.Collectors;

@Service
public class OrderBizDomainServiceImpl implements OrderBizDomainService {

    private static final Log log = Log.getLogger(OrderBizDomainServiceImpl.class);

    @Resource
    private OrderQueryRepository orderQueryRepositoryBiz;
    @Resource
    private OrderLineQueryRepository orderLineQueryRepositoryBiz;
    @Resource
    private BaseDataServiceAdapter baseDataServiceAdapter;
    @Resource
    private DictionaryVerifyAdapter dictionaryVerifyAdapter;

    @Override
    public Result<List<OrderLineBizQueryResponse>> pageQueryOrderLineList(OrderLineBizQueryRequest request) {
        try {
            OrderLineRepoQueryReq orderLineRepoQueryReq = OrderLineBizQueryRequestToOrderLineRepoQueryReqConvertor.convert(request);
            Result<List<OrderLineSDO>> response = orderLineQueryRepositoryBiz.pageQuery(orderLineRepoQueryReq);
            List<OrderLineBizQueryResponse> result = response.getResult().stream()
                    .map(OrderLineSDOToOrderLineBizQueryResponseConvertor::convert)
                    .collect(Collectors.toList());

            List<DictionaryResponse> allRefuseReason = baseDataServiceAdapter.queryDictionarys(ForecastConstants.DICT_REFUSE_REASON);
            List<DictionaryResponse> allOrderReason = baseDataServiceAdapter.queryDictionarys(ForecastConstants.DICT_ORDER_REASON);
            List<DictionaryResponse> allShipMethod = baseDataServiceAdapter.queryDictionarys(ForecastConstants.DICT_SHIP_METHOD);

            List<String> creatorIds = Nullable.stream(result).filter(x->StringUtils.isNotBlank(x.getCreatorId()) && StringUtils.isBlank(x.getCreatorWorkId())).map(x->{
                if (x.getCreatorId().startsWith("CZ_")){
                    //截取CZ_前缀
                    String creatorId = x.getCreatorId().substring(3);
                    return creatorId;
                }
                return x.getCreatorId();
            }).collect(Collectors.toList());
            List<String> updatorIds = Nullable.stream(result).filter(x->StringUtils.isNotBlank(x.getUpdatorId()) && StringUtils.isBlank(x.getUpdatorWorkId())).map(x-> {
                if (x.getUpdatorId().startsWith("CZ_")){
                    //截取CZ_前缀
                    String updatorId = x.getUpdatorId().substring(3);
                    return updatorId;
                }
                return x.getUpdatorId();
            }).collect(Collectors.toList());
            creatorIds.addAll(updatorIds);
            Map<String, Modifiers> employeeMap =  baseDataServiceAdapter.queryEmployeeMap(creatorIds);

            for (OrderLineBizQueryResponse orderResponse : result) {
                BigDecimal hundred = new BigDecimal(100);
                if (StringUtils.isNotBlank(orderResponse.getUnitPrice())) {
                    orderResponse.setUnitPrice(new BigDecimal(orderResponse.getUnitPrice()).divide(hundred,2, RoundingMode.UP).toString());
                }
                if (StringUtils.isNotBlank(orderResponse.getTotalAmount())) {
                    orderResponse.setTotalAmount(new BigDecimal(orderResponse.getTotalAmount()).divide(hundred,2, RoundingMode.UP).toString());
                }
                if (StringUtils.isNotBlank(orderResponse.getActivityUnitPrice())) {
                    orderResponse.setActivityUnitPrice(new BigDecimal(orderResponse.getActivityUnitPrice()).divide(hundred,2, RoundingMode.UP).toString());
                }
                if (StringUtils.isNotBlank(orderResponse.getActivityTotalAmount())) {
                    orderResponse.setActivityTotalAmount(new BigDecimal(orderResponse.getActivityTotalAmount()).divide(hundred,2, RoundingMode.UP).toString());
                }

                String creatorId = orderResponse.getCreatorId();
                if (StringUtils.isNotBlank(creatorId) && creatorId.startsWith("CZ_")){
                    creatorId = creatorId.substring(3);
                }
                if(StringUtils.isNotBlank(creatorId) && employeeMap.get(creatorId)!=null){
                    orderResponse.setCreatorWorkId(employeeMap.get(creatorId).getWorkId());
                }
                String updatorId = orderResponse.getUpdatorId();
                if (StringUtils.isNotBlank(updatorId) && updatorId.startsWith("CZ_")){
                    updatorId = updatorId.substring(3);
                }
                if(StringUtils.isNotBlank(updatorId) && employeeMap.get(updatorId)!=null){
                    orderResponse.setUpdatorWorkId(employeeMap.get(updatorId).getWorkId());
                }

                if (StringUtils.isNotBlank(orderResponse.getRefuseReasonCode()) && StringUtils.isBlank(orderResponse.getRefuseReasonName())) {
                    allRefuseReason.stream().forEach(x -> {
                        if (x.getCode().equals(orderResponse.getRefuseReasonCode())) {
                            orderResponse.setRefuseReasonName(x.getName());
                            return;
                        }
                    });
                }

                if (StringUtils.isNotBlank(orderResponse.getCreateReasonCode()) && StringUtils.isBlank(orderResponse.getCreateReasonName())) {
                    allOrderReason.stream().forEach(x -> {
                        if (x.getCode().equals(orderResponse.getCreateReasonCode())) {
                            orderResponse.setCreateReasonName(x.getName());
                            return;
                        }
                    });
                }

                if (StringUtils.isNotBlank(orderResponse.getDeliveryMethod()) && StringUtils.isBlank(orderResponse.getDeliveryMethodName())) {
                    allShipMethod.stream().forEach(x -> {
                        if (x.getCode().equals(orderResponse.getDeliveryMethod())) {
                            orderResponse.setDeliveryMethodName(x.getName());
                            return;
                        }
                    });
                }
            }
            return Result.listSuccess(result,response.getTotal());
        } catch (Exception e) {
            log.error("OrderBizDomainServiceImpl#pageQueryOrderLineList error", e);
            throw new FacadeException("OC-01-001-01-16-056");
        }
    }

    @Override
    public Result<OrderBizQueryResponse> queryOrderDetail(String id) {
        OrderSDO order = orderQueryRepositoryBiz.queryDetail(id);
        return Result.success(OrderSDOToOrderBizQueryResponseConvertor.convert(order));
    }

    @Override
    public Result<List<OrderBizQueryResponse>> queryOrderByFrontOrderId(String id) {
        Result<List<OrderSDO>> response = orderQueryRepositoryBiz.queryByFrontOrderId(id);
        List<OrderBizQueryResponse> result = response.getResult().stream().map(OrderSDOToOrderBizQueryResponseConvertor::convert).collect(Collectors.toList());
        return Result.listSuccess(result,response.getTotal());
    }

    @Override
    public Result<List<ObtcSaleOrderLineIndex>> loadDetailForPage(SalesOrderAtomPageQueryRequest request) {
        if (request.getPage() == null) {
            request.setPage(1);
        }
        if (request.getSize() == null) {
            request.setSize(10);
        }
        // 校验参数
        paramsAssert(request);
        // 查询ES
        return orderLineQueryRepositoryBiz.loadDetailForPage(request);
    }

    private void paramsAssert(SalesOrderAtomPageQueryRequest request) {
        String orderCategoryCode = request.getOrderCategoryCode();
        // 必填项校验
        AssertUtils.isTrue(org.apache.commons.lang.StringUtils.isBlank(request.getBusinessType()), "OC-01-001-01-15-001", "业态编码");

        // 长度校验
        AssertUtils.lengthCheck(request.getBusinessType(), 10, true, "OC-01-001-01-15-004", "业态编码");
        AssertUtils.lengthCheck(request.getFromSys(), 50, false, "OC-01-001-01-15-004", "来源系统编码");
        AssertUtils.lengthCheck(request.getBusinessUnitCode(), 50, false, "OC-01-001-01-15-004", "业务单元编码");
        AssertUtils.lengthCheck(request.getSalesOrderNo(), 50, false, "OC-01-001-01-15-004", "销售订单号");
        AssertUtils.lengthCheck(request.getPreOrderNo(), 50, false, "OC-01-001-01-15-004", "预报订单号");
        AssertUtils.lengthCheck(request.getOrderChannelCode(), 50, false, "OC-01-001-01-15-004", "订单渠道编码");
        AssertUtils.lengthCheck(request.getSourceOrderNo(), 50, false, "OC-01-001-01-15-004", "来源单号");
        AssertUtils.lengthCheck(request.getOutOrderNo(), 50, false, "OC-01-001-01-15-004", "外部单号");
        AssertUtils.lengthCheck(request.getProductGroupCode(), 50, false, "OC-01-001-01-15-004", "产品组编码");
        AssertUtils.lengthCheck(request.getBusinessChannelCode(), 50, false, "OC-01-001-01-15-004", "业务渠道编码");
        AssertUtils.lengthCheck(request.getSalesOrganizationCode(), 50, false, "OC-01-001-01-15-004", "销售组织编码");
        AssertUtils.lengthCheck(request.getCustomerCode(), 50, false, "OC-01-001-01-15-004", "售达方编码");
        AssertUtils.lengthCheck(request.getShipToPartyCode(), 50, false, "OC-01-001-01-15-004", "送达方编码");
        AssertUtils.lengthCheck(request.getCustomerGrade(), 50, false, "OC-01-001-01-15-004", "客户等级");
        AssertUtils.lengthCheck(request.getCustomerGroup(), 50, false, "OC-01-001-01-15-004", "客户组");
        AssertUtils.lengthCheck(request.getCreatorCode(), 50, false, "OC-01-001-01-15-004", "创建人工号");
        AssertUtils.lengthCheck(request.getCustomerPurchaseOrderNo(), 50, false, "OC-01-001-01-15-004", "客户采购订单号");
        AssertUtils.lengthCheck(request.getNote(), 255, false, "OC-01-001-01-15-004", "备注（主单）");
        AssertUtils.lengthCheck(request.getDeliveryFactoryCode(), 50, false, "OC-01-001-01-15-004", "发货工厂编码");
        AssertUtils.lengthCheck(request.getStockCode(), 50, false, "OC-01-001-01-15-004", "发货库存地点编码");
        AssertUtils.lengthCheck(request.getDetailNote(), 255, false, "OC-01-001-01-15-004", "订单行备注");
        AssertUtils.lengthCheck(request.getModifierCode(), 50, false, "OC-01-001-01-15-004", "修改人工号");
        AssertUtils.lengthCheck(request.getContact(), 50, false, "OC-01-001-01-15-004", "联系人");
        AssertUtils.lengthCheck(request.getContactPhone(), 50, false, "OC-01-001-01-15-004", "联系电话");
        AssertUtils.lengthCheck(request.getOrderBizTag(), 50, false, "OC-01-001-01-15-004", "订单标签");
        AssertUtils.lengthCheck(request.getIsClose(), 50, false, "OC-01-001-01-15-004", "是否关闭");

        AssertUtils.lengthCheckList(request.getKaSystemList(), "KA系统集合", "KA系统", 10, 50);
        AssertUtils.lengthCheckList(request.getKaAreaList(), "KA大区集合", "KA大区", 10, 50);
        AssertUtils.lengthCheckList(request.getOutOrderNoList(), "外部单号集合", "外部单号", 20, 50);
        AssertUtils.lengthCheckList(request.getBusinessUnitCodeList(), "业务单元编码集合", "业务单元编码", 10, 50);
        AssertUtils.lengthCheckList(request.getSalesOrderNoList(), "销售订单号集合", "销售订单号", 50, 50);
        AssertUtils.lengthCheckList(request.getSalesDepartmentCodeList(), "销售部门编码集合", "销售部门编码", 10, 50);
        AssertUtils.lengthCheckList(request.getPreOrderNoList(), "预报订单号集合", "预报订单号", 50, 50);
        AssertUtils.lengthCheckList(request.getSourceOrderNoList(), "来源单号集合", "来源单号", 50, 50);
        AssertUtils.lengthCheckList(request.getSalesDepartmentCodeList(), "销售部门编码集合", "销售部门编码", 10, 50);
        AssertUtils.lengthCheckList(request.getSalesChannelCodeList(), "销售渠道编码集合", "销售渠道编码", 10, 50);
        AssertUtils.lengthCheckList(request.getReceiveStatusList(), "单据收货状态集合", "单据收货状态", 10, 10);
        AssertUtils.lengthCheckList(request.getOrderChannelCodeList(), "订单渠道编码集合", "订单渠道编码", 10, 50);
        AssertUtils.lengthCheckList(request.getDetailReceiveStatusList(), "子单收货状态集合", "子单收货状态", 10, 10);
        AssertUtils.lengthCheckList(request.getStatusList(), "订单状态集合", "订单状态", 10, 10);
        AssertUtils.lengthCheckList(request.getDeliveryMethodCodeList(), "配送方式编码集合", "配送方式编码", 10, 50);
        AssertUtils.lengthCheckList(request.getOrderReasonCodeList(), "订单原因编码集合", "订单原因编码", 10, 50);
        AssertUtils.lengthCheckList(request.getReceiveWarehouseCodeList(), "收货仓（逻辑仓库编码）集合", "收货仓（逻辑仓库编码）", 10, 50);
        AssertUtils.lengthCheckList(request.getShippingWarehouseCodeList(), "发货仓（逻辑仓库编码）", "发货仓（逻辑仓库编码）", 10, 50);
        AssertUtils.lengthCheckList(request.getProductCodeList(), "物料编码集合", "物料编码", 10, 50);
        AssertUtils.lengthCheckList(request.getCloseReasonCodeList(), "关闭原因编码集合", "关闭原因编码", 10, 50);
        AssertUtils.lengthCheckList(request.getFromSysList(), "来源系统编码集合", "来源系统编码", 10, 50);
        AssertUtils.lengthCheckList(request.getDetailStatusList(), "明细行状态集合", "明细行状态", 10, 10);

        // 页码、页数合法性校验
        AssertUtils.isTrue(request.getPage() > MnOrderCenterConstants.MAX_PAGE().intValue(), "OC-01-001-01-15-009", "页数", "最大" + MnOrderCenterConstants.MAX_PAGE().intValue());
        AssertUtils.isTrue(request.getSize() > MnOrderCenterConstants.MAX_SIZE().intValue(), "OC-01-001-01-15-009", "分页条数", "最大" + MnOrderCenterConstants.MAX_SIZE().intValue());
        AssertUtils.isTrue(request.getPage() <= 0, "OC-01-001-01-15-009", "页数", "最小值为1");
        AssertUtils.isTrue(request.getSize() <= 0, "OC-01-001-01-15-009", "分页条数", "最小值为1");

        // 合法性校验
        dictionaryVerifyAdapter.verifyDictionary(DictionaryTypeEnum.BUSINESS_TYPE.getCode(), request.getBusinessType(), new FunctionException("OC-01-001-01-15-006", "业态编码"));
        if (CollectionUtils.isNotEmpty(request.getFromSysList())) {
            request.getFromSysList().forEach(fromSys ->
                dictionaryVerifyAdapter.verifyDictionary(DictionaryTypeEnum.FROM_SYS.getCode(), fromSys, new FunctionException("OC-01-001-01-15-006", "来源系统编码")));
        }
        if (StringUtils.isNotBlank(request.getFromSys())) {
            dictionaryVerifyAdapter.verifyDictionary(DictionaryTypeEnum.FROM_SYS.getCode(), request.getFromSys(), new FunctionException("OC-01-001-01-15-006", "来源系统编码"));
        }
        if (CollectionUtils.isNotEmpty(request.getBusinessUnitCodeList())) {
            request.getBusinessUnitCodeList().forEach(businessUnitCode ->
                    dictionaryVerifyAdapter.verifyDictionary(DictionaryTypeEnum.BUSINESS_UNIT_CODE.getCode(), businessUnitCode, new FunctionException("OC-01-001-01-15-006", "业务单元编码集合")));
        }
        if (StringUtils.isNotBlank(request.getBusinessUnitCode())) {
            dictionaryVerifyAdapter.verifyDictionary(DictionaryTypeEnum.BUSINESS_UNIT_CODE.getCode(), request.getBusinessUnitCode(), new FunctionException("OC-01-001-01-15-006", "业务单元编码"));
        }
        if (CollectionUtils.isNotEmpty(request.getOrderChannelCodeList())) {
            List<String> checkExistList = request.getOrderChannelCodeList().stream().filter(x -> !OrderChannelEnum.codes().contains(x)).collect(Collectors.toList());
            AssertUtils.isTrue(CollectionUtils.isNotEmpty(checkExistList), "OC-01-001-01-15-006", "订单渠道编码集合");
        }
        if (CollectionUtils.isNotEmpty(request.getReceiveStatusList())) {
            List<String> statusList = SalesOrderGroupReceiveStatusEnum.codes().stream().map(String::valueOf).collect(Collectors.toList());
            List<String> checkExistList = request.getReceiveStatusList().stream().filter(x -> !statusList.contains(x)).collect(Collectors.toList());
            AssertUtils.isTrue(CollectionUtils.isNotEmpty(checkExistList), "OC-01-001-01-15-006", "单据收货状态集合");
        }
        if (CollectionUtils.isNotEmpty(request.getDetailReceiveStatusList())) {
            List<String> statusList = SalesOrderGroupReceiveStatusEnum.codes().stream().map(String::valueOf).collect(Collectors.toList());
            List<String> checkExistList = request.getDetailReceiveStatusList().stream().filter(x -> !statusList.contains(x)).collect(Collectors.toList());
            AssertUtils.isTrue(CollectionUtils.isNotEmpty(checkExistList), "OC-01-001-01-15-006", "子单收货状态集合");
        }
        if (CollectionUtils.isNotEmpty(request.getStatusList())) {
            List<String> statusList = SalesOrderGroupStatusEnum.codes().stream().map(String::valueOf).collect(Collectors.toList());
            List<String> checkExistList = request.getStatusList().stream().filter(x -> !statusList.contains(x)).collect(Collectors.toList());
            AssertUtils.isTrue(CollectionUtils.isNotEmpty(checkExistList), "OC-01-001-01-15-006", "订单状态集合");
        }
        if (CollectionUtils.isNotEmpty(request.getDeliveryMethodCodeList())) {
            List<String> checkExistList = request.getDeliveryMethodCodeList().stream().filter(x -> !SalesOrderDeliveryMethodEnum.codes().contains(x)).collect(Collectors.toList());
            AssertUtils.isTrue(CollectionUtils.isNotEmpty(checkExistList), "OC-01-001-01-15-006", "配送方式编码集合");
        }
        if (CollectionUtils.isNotEmpty(request.getOrderReasonCodeList())) {
            List<String> checkExistList = request.getOrderReasonCodeList().stream().filter(x -> !SalesOrderReasonEnum.codes().contains(x)).collect(Collectors.toList());
            AssertUtils.isTrue(CollectionUtils.isNotEmpty(checkExistList), "OC-01-001-01-15-006", "订单原因编码集合");
        }
        if (CollectionUtils.isNotEmpty(request.getCloseReasonCodeList())) {
            List<String> checkExistList = request.getCloseReasonCodeList().stream().filter(x -> !SalesOrderCloseEnum.codes().contains(x)).collect(Collectors.toList());
            AssertUtils.isTrue(CollectionUtils.isNotEmpty(checkExistList), "OC-01-001-01-15-006", "关闭原因编码集合");
        }
        if (CollectionUtils.isNotEmpty(request.getDetailStatusList())) {
            List<String> detailStatusList = SalesOrderGroupStatusEnum.codes().stream().map(String::valueOf).collect(Collectors.toList());
            List<String> checkExistList = request.getDetailStatusList().stream().filter(x -> !detailStatusList.contains(x)).collect(Collectors.toList());
            AssertUtils.isTrue(CollectionUtils.isNotEmpty(checkExistList), "OC-01-001-01-15-006", "明细行状态集合");
        }
        if (StringUtils.isNotEmpty(request.getOrderBizTag())) {
            AssertUtils.isTrue(!OrderBizTagEnum.codes().contains(request.getOrderBizTag()), "OC-01-001-01-15-006", "订单标签");
        }
        AssertUtils.isWholeNumber(request.getContactPhone(), false, "OC-01-001-01-15-006", "联系电话");
        if (StringUtils.isNotBlank(request.getFulfillmentTypeCode())) {
            AssertUtils.isTrue(request.getFulfillmentTypeCode().length() > 50, "OC-01-001-01-15-004", "履约方式", request.getFulfillmentTypeCode().length(), "50");
            // 履约方式枚举校验
            if (OrderCategoryEnum.GROUP.getCode().equals(orderCategoryCode)) {
                List<DictionaryResponse> fulfillmentTypeList = baseDataServiceAdapter.queryDictionarys(DictionaryTypeEnum.GROUP_SALE_FULFILLMENT_TYPE.getCode());
                Map<String, DictionaryResponse> fulfillmentTypeMap = fulfillmentTypeList.stream().collect(Collectors.toMap(DictionaryResponse::getCode, Function.identity(), (k1, k2) -> k2));
                DictionaryResponse dictionaryResponse = fulfillmentTypeMap.get(request.getFulfillmentTypeCode());
                AssertUtils.isTrue(dictionaryResponse == null, "OC-01-001-01-15-006", "履约方式");
            } else {
                List<DictionaryResponse> fulfillmentTypeList = baseDataServiceAdapter.queryDictionarys(DictionaryTypeEnum.COMPANY_SALE_FULFILLMENT_TYPE.getCode());
                Map<String, DictionaryResponse> fulfillmentTypeMap = fulfillmentTypeList.stream().collect(Collectors.toMap(DictionaryResponse::getCode, Function.identity(), (k1, k2) -> k2));
                AssertUtils.isTrue(fulfillmentTypeMap.get(request.getFulfillmentTypeCode()) == null, "OC-01-001-01-15-006", "履约方式");
            }
        }
        if (StringUtils.isNotBlank(request.getFulfillmentPriority())) {
            AssertUtils.isTrue(request.getFulfillmentPriority().length() > 10, "OC-01-001-01-15-004", "履约优先级", request.getFulfillmentPriority().length(), "10");
            // 履约优先级枚举校验 0 100
            FulfillmentPriorityEnum fulfillmentPriorityEnum = FulfillmentPriorityEnum.of(request.getFulfillmentPriority());
            AssertUtils.isTrue(Objects.isNull(fulfillmentPriorityEnum), "OC-01-001-01-15-006", "履约优先级");
        }
        // 是否关闭合法校验
        if (StringUtils.isNotBlank(request.getIsClose())) {
            AssertUtils.isTrue(!Lists.newArrayList(GeneralStatusEnum.YES.getCode().toString(), GeneralStatusEnum.NO.getCode().toString()).contains(request.getIsClose()), "OC-01-001-01-15-006", "是否关闭");
        }

        // 时间格式确认
        Map<String, String> expectedDeliveryTimeMap = AssertUtils.timeFormatCheck(request.getExpectedDeliveryBeginDate(), request.getExpectedDeliveryEndDate(), "期望交货日期（开始日期）", "期望交货日期（结束日期）", AssertUtils.TYPE_DATE);
        Map<String, String> createTimeMap = AssertUtils.timeFormatCheck(request.getCreateBeginTime(), request.getCreateEndTime(), "创建时间（开始时间）", "创建时间（结束时间）", AssertUtils.TYPE_TIME);
        Map<String, String> updateTimeMap = AssertUtils.timeFormatCheck(request.getModifyBeginTime(), request.getModifyEndTime(), "修改时间（开始时间）", "修改时间（结束时间）", AssertUtils.TYPE_TIME);
        Map<String, String> sourceTime = AssertUtils.timeFormatCheck(request.getSourceBeginTime(), request.getSourceEndTime(), "来单时间（开始时间）", "来单时间（结束时间）", AssertUtils.TYPE_TIME);
        request.setExpectedDeliveryBeginDate(expectedDeliveryTimeMap.get(AssertUtils.START_TIME));
        request.setExpectedDeliveryEndDate(expectedDeliveryTimeMap.get(AssertUtils.END_TIME));
        request.setCreateBeginTime(createTimeMap.get(AssertUtils.START_TIME));
        request.setCreateEndTime(createTimeMap.get(AssertUtils.END_TIME));
        request.setModifyBeginTime(updateTimeMap.get(AssertUtils.START_TIME));
        request.setModifyEndTime(updateTimeMap.get(AssertUtils.END_TIME));
        request.setSourceBeginTime(sourceTime.get(AssertUtils.START_TIME));
        request.setSourceEndTime(sourceTime.get(AssertUtils.END_TIME));
    }
}
